<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="primus" tagdir="/WEB-INF/tags" %>
<primus:page title="门店列表">
    <jsp:attribute name="css">
        <style type="text/css">

        </style>
    </jsp:attribute>
    <jsp:attribute name="script">
        <script type="application/javascript">
            <sec:authorize access="hasAuthority('OPT_DEPOT_UPDATE')">

            function save() {
                var depotCode = $("#depotCode").val();
                var status = $("#status").prop("checked");
                var enableStatus = "DISABLE";
                if (status) {
                    enableStatus = "ENABLE";
                }
                $.ajax({
                        "url": "${contextPath}/depots/updateStatus.do",
                        "type": "post",
                        "data": {
                            depotCode: depotCode,
                            enableStatus: enableStatus
                        },
                        "dataType": "json",
                        "error": function () {
                            layer.alert("服务器出错", 2);
                        },
                        "success": function () {
                            layer.msg("数据提交成功");
                            setTimeout(function () {
                                window.location.href = "/depots/list.do";
                            }, 1500)
                        }
                    }
                );
            }
            </sec:authorize>
        </script>
    </jsp:attribute>
    <jsp:body>
        <%--<jsp:include page="../demo/cats/component/navigations.jsp"/>--%>
        <div class="breadcrumbs ace-save-state" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="welcome.do">
                        首页
                    </a>
                </li>
                <li>
                    门店管理
                </li>
                <li class="active">
                    门店列表
                </li>
            </ul>
        </div>

        <div class="page-content">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            <span>门店主数据信息</span>
                            <button type="button" class="pull-right">
                                <a href="${contextPath}/depots/list.do">&lt;&lt;返回列表</a>
                            </button>
                        </div>
                        <div class="panel-body pan">
                            <table class="table table-bordered table-striped">
                                <input type="hidden" id="depotCode" value="${depot.depotCode}">
                                <tr align="center">
                                    <td>门店编码</td>
                                    <td><input readonly type="text" class="form-control"
                                               value="${depot.depotCode}"/>
                                    <td>门店名称</td>
                                    <td><input readonly type="text" class="form-control"
                                               value="${depot.name}"/>
                                </tr>
                                <tr align="center">
                                    <td>门店类型</td>
                                    <td><input readonly type="text" class="form-control"
                                               value="${depot.depotType}"/>
                                    <td>门店地址</td>
                                    <td><input readonly type="text" class="form-control"
                                               value="${depot.address}"/>
                                </tr>
                                <tr align="center">
                                    <td>门店营业开始时间</td>
                                    <td><input readonly type="text" class="form-control"
                                               value="<fmt:formatDate value='${depot.beginBusiness}' pattern='HH:mm:ss'/>"/>
                                    <td>门店营业结束时间</td>
                                    <td><input readonly type="text" class="form-control"
                                               value="<fmt:formatDate value='${depot.endBusiness}' pattern='HH:mm:ss'/>"/>
                                </tr>
                                <tr align="center">
                                    <td>门店经纬度</td>
                                    <td><input readonly type="text" class="form-control"
                                               value="${depot.depotLongitude},${depot.depotLatitude}"/>
                                    <td>是否开启</td>
                                    <td>
                                        <div class="col-xs-3">
                                            <label>
                                                <input ${depot.enableStatus == 'ENABLE'?'checked':''}
                                                        id="status" class="ace ace-switch" type="checkbox"/>
                                                <span class="lbl"></span>
                                            </label>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                            <div class="form-actions">
                                <sec:authorize access="hasAuthority('OPT_DEPOT_UPDATE')">
                                    <div class="col-md-offset-3 col-md-9">
                                        <button type="button" class="btn btn-primary" onclick="save()">保存</button>
                                    </div>
                                </sec:authorize>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </jsp:body>
</primus:page>
